home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Full / NetObjects Fusion 9 Standard / NOF9_Full_EN.exe / data1.cab / FSI / lib / innovative / menu.js < prev    next >
Encoding:
JavaScript  |  2005-11-16  |  19.5 KB  |  819 lines

  1. /****i* SOURCE_FILE/INFO
  2.  *
  3.  * NAME
  4.  *  menu.js
  5.  *
  6.  * USAGE
  7.  *  Part of IS JavaScript Library.
  8.  *
  9.  * COPYRIGHT
  10.  *  Copyright ⌐ 1999-2000 Innovative Systems SRL.
  11.  *  All Rights Reserved.
  12.  *
  13.  *  This is an unpublished work protected by Innovative Systems SRL
  14.  *  as a trade secret, and is not to be used or disclosed except as
  15.  *  expressly provided in a written license agreement executed by
  16.  *  you and Innovative Systems SRL.
  17.  *
  18.  *      <copyright@innovative.ro>
  19.  *
  20.  * NOTES
  21.  *  JavaScript code.
  22.  *
  23.  *****/
  24.  
  25. /****h* IS_JavaScript_Library/menu
  26.  *
  27.  * NAME
  28.  *  IS JavaScript Library / menu module
  29.  *
  30.  * DESCRIPTION
  31.  *  Menu related functionality.
  32.  *
  33.  ****/
  34.  
  35. var IS = IS_getLibHandle();
  36.  
  37.  
  38. if (typeof (IS) != "undefined" && typeof (IS.Location) == "undefined")
  39. {
  40. /****c* ISJS/Location
  41.  *
  42.  * NAME
  43.  *  ISJS::Location (id, target, href)
  44.  *
  45.  * USAGE
  46.  *  id     -- Object identifier.
  47.  *            Distinguishes the location within a locations collection.
  48.  *            Should be unique among the collection.
  49.  *  target -- Name of a frame within the browser.
  50.  *  href   -- Uniform Resource Locator (the URL) to be loaded by the browser.
  51.  *
  52.  * DESCRIPTION
  53.  *    By selecting a tree or menu item an ôactionö is usually performed. Within IS
  54.  *  JavaScript library such an ôactionö is translated to one or more commands given to the
  55.  *  browser to load a specified URL into a specified frame.
  56.  *    ISJS::Location objects gather together these two pieces of information: a target
  57.  *  browser frame (target property) and an URL (href property).
  58.  *    Every item, both menu and tree, has associated a collection of locations retaining
  59.  *  thus the actions attached to them.
  60.  *
  61.  * SEE ALSO
  62.  *  Container, Menu, Tree.
  63.  *
  64.  ****/
  65. function IS_Location (target, href)
  66. {
  67.   // __proto__ initialization
  68.   this.__proto__ = IS_Location.prototype;
  69.  
  70.   // properties
  71.   //this.id = id;
  72.   this.target = target;
  73.   this.href = href;
  74. }
  75.  
  76. // add Location class to IS namespace
  77. IS.__proto__.Location = IS_Location;
  78. }
  79.  
  80. if (typeof (IS) != "undefined" && typeof(IS.Menu) == "undefined")
  81. {
  82.  
  83.  
  84. /****m* MenuItem/select
  85.  *
  86.  * NAME
  87.  *  select ()
  88.  *
  89.  * DESCRIPTION
  90.  *  Action when a menu item is selected.
  91.  *  Separated into a method to make it overridable in sub-classes.
  92.  *
  93.  * RETURN VALUE
  94.  *  none
  95.  *
  96.  ****/
  97. function IS_Menu_Item_select ()
  98. {
  99.   var menu = this.owner;
  100.   var document = menu.document;
  101.  
  102.   // clear previous selection
  103.   var ignoreItemId = this.id;
  104.   menu.clearSelection (ignoreItemId);
  105.  
  106.   // load associated locations
  107.   var nLocationCount = this.locations.length;
  108.  
  109.   // first location (i = 0) already proceesed (see toHtml() method)
  110.   for (var i = 1; i < nLocationCount; i++)
  111.   {
  112.     var location = this.locations[i];
  113.     if (typeof (IS.incHidden) != "undefined" && IS.incHidden == true && location.target == IS.HiddenFrame.frame.name)
  114.     {
  115.       eval (location.href);
  116.     }
  117.     else
  118.     {
  119.       var target = IS.getFrameByName (location.target);
  120.       if (null != target)
  121.       {
  122.         target.location.replace( location.href );
  123.       }
  124.       else
  125.       {
  126.         //alert( "Invalid frame name specified (" + location.target + ")!"
  127.         //      + "\n Review Menu initialization." );
  128.       }
  129.     }
  130.   }
  131. }
  132.  
  133.  
  134. /****m* MenuItem/setCompleted
  135.  *
  136.  * NAME
  137.  *  setCompleted (isCompleted)
  138.  *
  139.  * USAGE
  140.  *
  141.  * DESCRIPTION
  142.  *    Sets item status as completed. If the item status changed (from uncompleted to
  143.  *  completed) statusChange() method is called.
  144.  *
  145.  * RETURN VALUE
  146.  *  none
  147.  *
  148.  ****/
  149. function IS_Menu_Item_setCompleted (isCompleted)
  150. {
  151.   isCompleted = (isCompleted == null ? true : isCompleted);
  152.   if (this.isCompleted != isCompleted)
  153.   {
  154.     this.isCompleted = isCompleted;
  155.   }
  156. }
  157.  
  158. /****m* MenuItem/setSelected
  159.  *
  160.  * NAME
  161.  *  setSelected (isSelected)
  162.  *
  163.  * USAGE
  164.  *
  165.  * DESCRIPTION
  166.  *    Sets item status as selected. If the item status changed (from unselected to
  167.  *  selected) statusChange() method is called.
  168.  *
  169.  * RETURN VALUE
  170.  *  none
  171.  *
  172.  ****/
  173. function IS_Menu_Item_setSelected (isSelected)
  174. {
  175.   isSelected = (isSelected == null ? true : isSelected);
  176.   if (this.isSelected != isSelected)
  177.   {
  178.     this.isSelected = isSelected;
  179.   }
  180. }
  181.  
  182.  
  183. /****m* MenuItem/setFocused
  184.  *
  185.  * NAME
  186.  *  setFocused (isFocused)
  187.  *
  188.  * USAGE
  189.  *
  190.  * DESCRIPTION
  191.  *    Sets item status as focused. If the item status changed (from unfocused to
  192.  *  focused) statusChange() method is called.
  193.  *
  194.  * RETURN VALUE
  195.  *  none
  196.  *
  197.  ****/
  198. function IS_Menu_Item_setFocused (isFocused)
  199. {
  200.   isFocused = (isFocused == null ? true : isFocused);
  201.   if (this.isFocused != isFocused)
  202.   {
  203.     this.isFocused = isFocused;
  204.     if (typeof ("top") != "undefined" && typeof ("top.status") != "undefined")
  205.     {
  206.       top.status = (isFocused ? this.tip : "");
  207.     }
  208.   }
  209. }
  210.  
  211.  
  212. /****m* MenuItem/onMouseOver
  213.  *
  214.  * NAME
  215.  *  onMouseOver()
  216.  *
  217.  * USAGE
  218.  *
  219.  * DESCRIPTION
  220.  *  Called (by browser) when the mouse enters the image associated to the item.
  221.  *
  222.  * RETURN VALUE
  223.  *  none
  224.  *
  225.  ****/
  226. function IS_Menu_Item_onMouseOver()
  227. {
  228.   this.setFocused (true);
  229. }
  230.  
  231.  
  232. /****m* MenuItem/onMouseOut
  233.  *
  234.  * NAME
  235.  *  onMouseOut()
  236.  *
  237.  * USAGE
  238.  *
  239.  * DESCRIPTION
  240.  *  Called (by browser) when the mouse exits the image associated to the item.
  241.  *
  242.  * RETURN VALUE
  243.  *  none
  244.  *
  245.  ****/
  246. function IS_Menu_Item_onMouseOut()
  247. {
  248.   this.setFocused (false);
  249. }
  250.  
  251.  
  252. /****m* MenuItem/onClick
  253.  *
  254.  * NAME
  255.  *  onClick()
  256.  *
  257.  * USAGE
  258.  *
  259.  * DESCRIPTION
  260.  *  Called (by browser) when the mouse clicks the image associated to the item.
  261.  *
  262.  * RETURN VALUE
  263.  *  none
  264.  *
  265.  ****/
  266. function IS_Menu_Item_onClick()
  267. {
  268.   this.setSelected (true);
  269.   this.select ();
  270. }
  271.  
  272. /****m* MenuItem/toHTML
  273.  *
  274.  * NAME
  275.  *  toHTML (menu)
  276.  *  toHTML (target, href)
  277.  *
  278.  * USAGE
  279.  *  menu -- Menu object to which this item belongs.
  280.  *
  281.  * DESCRIPTION
  282.  *  Generates the HTML document portion corresponding to the item.
  283.  *
  284.  * RETURN VALUE
  285.  *  none
  286.  *
  287.  ****/
  288.  
  289. function IS_Menu_Item_toHTMLItemF (self, target, href)
  290. {
  291.   var varName = self.owner.varName;
  292.   return (
  293.        "<A NAME=\"" + self.id + "\"" +
  294.          (this.isSelected
  295.               ? "HREF=\"javascript:void 0\""
  296.               : "\" TARGET=\"" + target + "\" HREF=\"" + href + "\"") +
  297.        "   onMouseOver=\"" + varName + ".getItem(\'" + self.id + "\').onMouseOver();\"" +
  298.        "   onMouseOut=\"" + varName + ".getItem(\'" + self.id + "\').onMouseOut();\"" +
  299.        "   onClick=\"" + varName + ".getItem(\'" + self.id + "\').onClick();\">" +
  300.        self.label +
  301.        "</A>" );
  302. }
  303.  
  304. function IS_Menu_Item_toHTML (itemF)
  305. {
  306.     if (itemF == null)
  307.         { itemF = IS_Menu_Item_toHTMLItemF; }
  308.  
  309.     var document = this.owner.document;
  310.     var target = null;
  311.     var href = null;
  312.  
  313.     if (this.locations.length > 0)
  314.     {
  315.         var firstLocation = this.locations[0];
  316.         target = firstLocation.target;
  317.         href = firstLocation.href;
  318.     }
  319.  
  320.     document.writeln (itemF (this, target, href));
  321. }
  322.  
  323.  
  324. /****c* ISJS/MenuItem
  325.  *
  326.  * NAME
  327.  *  ISJS::MenuItem( id, owner, tip, resCompleted, resUncompleted )
  328.  *
  329.  * USAGE
  330.  *  id             -- Object identifier.
  331.  *                    Distinguishes the item within the collection of the menu items
  332.  *  owner          -- ISJS::Menu object to which this item belongs. Do not change this property
  333.  *  tip            -- Tooltip associated to the item
  334.  *  label          -- the label for this menu item
  335.  *
  336.  * DESCRIPTION
  337.  *    A menu item has the following characteristics:
  338.  *    - label;
  339.  *    - status;
  340.  *    - tip;
  341.  *    - menu (to which it belongs);
  342.  *    - associated action(s).
  343.  *
  344.  *    The item is presented to the user through its depiction, typically a label or an image.
  345.  *
  346.  *    The item status is a combination of three conditions:
  347.  *    - completed / uncompleted;
  348.  *    - selected / unselected;
  349.  *    - focused / unfocused.
  350.  *
  351.  *    The item status depends on the mouse position to item image and user action:
  352.  *    - when the user clicks the item image, the item goes into selected status. A menu can
  353.  *  have at most one selected item at a time. Thus, an item selection causes the transition of
  354.  *  every other item to the unselected status.
  355.  *    - when the mouse enters the item, the item goes into focused status. When the
  356.  *  mouse exits the item, the item goes into unfocused status;
  357.  *    - the completed / uncompleted status is not directly accessed by the user; it is
  358.  *  programmatically managed through the setCompleted() / clearCompleted() method pair.
  359.  *
  360.  *    Selecting an item will tell the browser to execute its associated actions; the actions
  361.  *  are translated into URL calls (see IS.Location description for more details). The
  362.  *  browser status will be set with the item tip.
  363.  *
  364.  *    A menu item belongs to a menu (the menu has, usually, a collection of items). To be
  365.  *  identified in the item collection a menu item has to have a distinct identifier (id
  366.  *  property.)
  367.  *
  368.  *    A menu item is capable (aided by the menu to which it belongs) to generate its HTML
  369.  *  representation (toHtml() method.)
  370.  *
  371.  * NOTES
  372.  *
  373.  * SEE ALSO
  374.  *  Menu, SelectableRes
  375.  *
  376.  ****/
  377. function IS_MenuItem (id, label, tip, locations, owner)
  378. {
  379.   // __proto__ initialization
  380.   this.__proto__ = IS_MenuItem.prototype;
  381.  
  382.   // properties
  383.   this.id    = id;     // must be unique among the menu item collection
  384.   this.label = label;  // menu label (text or image)
  385.   this.tip   = tip;    // menu item's tooltip on the status bar
  386.   this.owner = owner;  // menu item's owner (if any)
  387.  
  388.                          // locations loaded on selection
  389.   this.locations = (
  390.          (locations != null)
  391.           ? ((typeof (locations.length) != "undefined") ? locations : new Array (locations))
  392.               : (new Array (0)));
  393.  
  394.   // status flag(s)
  395.   this.isCompleted = false; // none, one or many (possible all) item(s) on a menu may be completed at a time
  396.   this.isSelected  = false; // none or one item on a menu may be selected at a time
  397.   this.isFocused   = false; // none or one item on a menu may be focused at a time
  398.  
  399.     // methods
  400.   // ...status related
  401.   this.setCompleted = IS_Menu_Item_setCompleted;
  402.   this.setSelected  = IS_Menu_Item_setSelected;
  403.   this.setFocused   = IS_Menu_Item_setFocused;
  404.  
  405.   // ...action related
  406.   this.select       = IS_Menu_Item_select;
  407.  
  408.   // ...event handler(s)
  409.   this.onMouseOver  = IS_Menu_Item_onMouseOver;
  410.   this.onMouseOut   = IS_Menu_Item_onMouseOut;
  411.   this.onClick    = IS_Menu_Item_onClick;
  412.  
  413.   // ...HTML related
  414.   this.toHTML = IS_Menu_Item_toHTML;   // HTML reflection of the menu item
  415. }
  416.  
  417. // add MenuItem class to IS namespace
  418. IS.__proto__.MenuItem = IS_MenuItem;
  419.  
  420.  
  421.  
  422.  
  423. /****m* Menu/getItemCount
  424.  *
  425.  * NAME
  426.  *  getItemCount()
  427.  *
  428.  * USAGE
  429.  *
  430.  * DESCRIPTION
  431.  *  Finds out the total number of the items managed by the menu.
  432.  *
  433.  * RETURN VALUE
  434.  *  Number of the menu items (objects) within the menu.
  435.  *
  436.  ****/
  437. function IS_Menu_getItemCount()
  438. {
  439.   return this.items.length;
  440. }
  441.  
  442.  
  443. /****m* Menu/getItemPos
  444.  *
  445.  * NAME
  446.  *  getItemPos( itemId )
  447.  *
  448.  * USAGE
  449.  *  itemId -- the identifier of the item whose position is to be retrieved
  450.  *
  451.  * DESCRIPTION
  452.  *  Retrieves the position of an item from the menu collection.
  453.  *
  454.  * RETURN VALUE
  455.  *  [integer] -û the position of the element if successful (the menu collection contains an item
  456.  *                with the specified identifier)
  457.  *  -1        û- otherwise
  458.  *
  459.  ****/
  460. function IS_Menu_getItemPos (itemId)
  461. {
  462.   var nItemCount = this.items.length;
  463.   for (var i = 0; i < nItemCount; i++)
  464.   {
  465.     if (this.items[i].id == itemId)
  466.     {
  467.       return i;
  468.     }
  469.   }
  470.  
  471.   return -1;
  472. }
  473.  
  474.  
  475. /****m* Menu/getItem
  476.  *
  477.  * NAME
  478.  *  getItem( itemId )
  479.  *
  480.  * USAGE
  481.  *  itemId -- the identifier of the item to be retrieved
  482.  *
  483.  * DESCRIPTION
  484.  *  Retrieves an item from the menu collection.
  485.  *
  486.  * RETURN VALUE
  487.  *  [object] -û ISJS::MenuItem object, if successful (the menu collection contains an item
  488.  *              with the specified identifier)
  489.  *  null     û- in any other case
  490.  *
  491.  ****/
  492. function IS_Menu_getItem (itemId)
  493. {
  494.   var pos = this.getItemPos (itemId);
  495.   return (pos == -1 ? null : this.items[pos]);
  496. }
  497.  
  498.  
  499. /****m* Menu/setItem
  500.  *
  501.  * NAME
  502.  *  setItem( itemId, newItem )
  503.  *
  504.  * USAGE
  505.  *  itemId  -- the identifier of the item to be replaced
  506.  *  newItem -- the new item which will replace the one with the identifier æitemIdÆ
  507.  *
  508.  * DESCRIPTION
  509.  *  Replaces a menu item.
  510.  *
  511.  * RETURN VALUE
  512.  *  true  -û if successful (the item was changed)
  513.  *  false û- if failed.
  514.  *
  515.  * NOTES
  516.  *  (*) The request to change an item with a non-existent id within the menu collection will
  517.  *      fail.
  518.  *
  519.  ****/
  520. function IS_Menu_setItem( itemId, newItem )
  521. {
  522.   newItem.owner = this;
  523.   var item = this.getItem( itemId );
  524.   if (item != null)
  525.   {
  526.     for ( var prop in item )
  527.       if ( prop != "id" )
  528.         eval( "item." + prop + " = newItem." + prop );
  529.  
  530.     return true;
  531.   }
  532.  
  533.   return false;
  534. }
  535.  
  536.  
  537. /****m* Menu/addItem
  538.  *
  539.  * NAME
  540.  *  addItem( newItem )
  541.  *
  542.  * USAGE
  543.  *  newItem -- object to be added (of type ISJS::MenuItem)
  544.  *
  545.  * DESCRIPTION
  546.  *  Adds a new item to the menu collection.
  547.  *
  548.  * RETURN VALUE
  549.  *  true  -û if successful (the new item was added)
  550.  *  false û- if failed
  551.  *
  552.  ****/
  553. function IS_Menu_addItem (newItem)
  554. {
  555.   newItem.owner = this;
  556.   this.items[this.items.length] = newItem; // this.items.push (newItem);
  557. }
  558.  
  559.  
  560. /****m* Menu/removeItem
  561.  *
  562.  * NAME
  563.  *  removeItem( itemId )
  564.  *
  565.  * USAGE
  566.  *  itemId -- the identifier of the item to be removed
  567.  *
  568.  * DESCRIPTION
  569.  *  Removes an item from the menu collection.
  570.  *
  571.  * RETURN VALUE
  572.  *  true  -û if successful (the item was removed)
  573.  *  false û- if failed
  574.  *
  575.  * NOTES
  576.  *  (*) The request to remove an item with a non-existent id within the menu collection will
  577.  *      fail.
  578.  *
  579.  ****/
  580. function IS_Menu_removeItem (itemId)
  581. {
  582.   var pos = this.getItemPos (itemId);
  583.   if (pos != -1)
  584.   {
  585.     this.items.splice (pos, 1);
  586.     return true;
  587.   }
  588.   else
  589.   {
  590.     return false;
  591.   }
  592.  
  593. }
  594.  
  595.  
  596. /****m* Menu/clearSelection
  597.  *
  598.  * NAME
  599.  *  clearSelection (ignoreItemId)
  600.  *
  601.  * USAGE
  602.  *  ignoreItemId -- the identifier of the menu item to be ignored
  603.  *
  604.  * DESCRIPTION
  605.  *    Sets the items within the menu collection to unselected status, except for the
  606.  *  specified item.
  607.  *
  608.  * RETURN VALUE
  609.  *  none
  610.  *
  611.  ****/
  612. function IS_Menu_clearSelection (ignoreItemId)
  613. {
  614.   for (var i = 0; i < this.items.length; i++)
  615.   {
  616.     var item = this.items[i];
  617.     if (item.id != ignoreItemId)
  618.     {
  619.       item.setSelected (false);
  620.     }
  621.   }
  622. }
  623.  
  624.  
  625. /****m* Menu/setSelected
  626.  *
  627.  * NAME
  628.  *  setSelected (itemId, isSelected)
  629.  *
  630.  * USAGE
  631.  *
  632.  * DESCRIPTION
  633.  *    Sets item status as selected. The selection status of all other items is cleared.
  634.  *
  635.  * RETURN VALUE
  636.  *  none
  637.  *
  638.  ****/
  639. function IS_Menu_setSelected (itemId, isSelected)
  640. {
  641.   isSelected = (isSelected == null ? true : isSelected);
  642.   var item = this.getItem (itemId);
  643.   if (item != null)
  644.   {
  645.     if (isSelected)
  646.     {
  647.       this.clearSelection (itemId);
  648.     }
  649.     item.setSelected (isSelected);
  650.     this.redraw ();
  651.   }
  652. }
  653.  
  654. /****m* Menu/toHtml
  655.  *
  656.  * NAME
  657.  *  toHtml()
  658.  *
  659.  * USAGE
  660.  *
  661.  * DESCRIPTION
  662.  *  Creates the HTML portion of the document corresponding to the menu.
  663.  *
  664.  * RETURN VALUE
  665.  *  none
  666.  *
  667.  ****/
  668. function IS_Menu_toHTMLHeaderF ()
  669. {
  670.   return (
  671.     "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\">\n" +
  672.     "  <TR>\n" +
  673.     "    <TD>\n");
  674. }
  675.  
  676. function IS_Menu_toHTMLFooterF ()
  677. {
  678.   return (
  679.     "    </TD>\n" +
  680.     "  </TR>\n" +
  681.     "</TABLE>");
  682. }
  683.  
  684. function IS_Menu_toHTML (headerF, itemF, footerF)
  685. {
  686.   var document = this.document;
  687.  
  688.   if (headerF == null)
  689.      { headerF = (this.toHTMLHeaderF != null ? this.toHTMLHeaderF : IS_Menu_toHTMLHeaderF); }
  690.   if (itemF == null)
  691.      { itemF = (this.toHTMLItemF != null ? this.toHTMLItemF : null); }
  692.   if (footerF == null)
  693.      { footerF = (this.toHTMLFooterF != null ? this.toHTMLFooterF : IS_Menu_toHTMLFooterF); }
  694.  
  695.   document.write (headerF ());
  696.  
  697.   var items = this.items;
  698.   for (var i = 0; i < items.length; i++)
  699.   {
  700.     var menuItem = items[i];
  701.     if (menuItem.owner == null)
  702.       { menuItem.owner = this; }
  703.  
  704.     menuItem.toHTML (itemF);
  705.  
  706.     if (this.direction == this.DIRECTION_VERTICAL)
  707.       document.writeln ("<BR>");
  708.   }
  709.  
  710.   document.write (footerF ());
  711. }
  712.  
  713.  
  714. /****m* Menu/redraw
  715.  *
  716.  * NAME
  717.  *  redraw()
  718.  *
  719.  * USAGE
  720.  *
  721.  * DESCRIPTION
  722.  *  Generates a menu redraw event.
  723.  *
  724.  * RETURN VALUE
  725.  *  none
  726.  *
  727.  ****/
  728. function IS_Menu_redraw ()
  729. {
  730.   if (this.document != null)
  731.   {
  732.     this.document.location.reload();
  733.   }
  734. }
  735.  
  736.  
  737. /****c* ISJS/Menu
  738.  *
  739.  * NAME
  740.  *  ISJS::Menu(id, varName, owner)
  741.  *
  742.  * USAGE
  743.  *  id      -- Object identifier.
  744.  *             Distinguishes the menu within a menu collection.
  745.  *  varName -- Name of the JavaScript variable representing this menu (used within
  746.  *             toHtml() method.)
  747.  *  owner   -- This property is currently not used.
  748.  *
  749.  * DESCRIPTION
  750.  *    A menu offers to the user a quick and easy navigation among many options (using menu
  751.  *  items; see ISLib.MenuItem for details.) There are no direct relations between those
  752.  *  multiple options; they all have the same importance. There are no submenus (like in common
  753.  *  Windows applications.)
  754.  *
  755.  *    A menu is responsible to create its representation in HTML format (toHtml() method.)
  756.  *  This requirement implies that the menu should have access to the object representing the
  757.  *  HTML document to which it belongs (document property) and acknowledge the name of the
  758.  *  variable under which it is instantiated (varName property.) Both properties (document and
  759.  *  varName) might be modified during the life of a menu.
  760.  *
  761.  *    A menu has associated a unique identifier (id property), which allows the creation of
  762.  *  menu collections (see ISLib.Container for details.) Within a collection the identifier of
  763.  *  a menu should be unique.
  764.  *
  765.  * NOTES
  766.  *  (*) It is possible that the menu variable to be created before the creation of the HTML
  767.  *      document which will contain it; in this case the document property of the menu should
  768.  *      be properly set up when the HTML document is created (if possible in the <HEAD> tag
  769.  *      section.)
  770.  *
  771.  * SEE ALSO
  772.  *  MenuItem
  773.  *
  774.  ****/
  775. function IS_Menu (id, varName, toHTMLFs, owner)
  776. {
  777.   // __proto__ initialization
  778.   this.__proto__ = IS_Menu.prototype;
  779.  
  780.   // properties
  781.   this.id     = id;
  782.   this.owner    = owner;
  783.   this.varName  = varName;              // name of the variable which hold the menu (used to create the HMTL)
  784.   this.document = null;               // browser document which includes the menu (late binding)
  785.   this.items    = new Array(0);
  786.  
  787.   if (toHTMLFs != null && typeof(toHTMLFs.length) != "undefined" && toHTMLFs.length == 3)
  788.   {
  789.     this.toHTMLHeaderF = toHTMLFs[0];
  790.     this.toHTMLItemF   = toHTMLFs[1];
  791.     this.toHTMLFooterF = toHTMLFs[2];
  792.   }
  793.  
  794.   // displayed direction (horizontal vs. vertical)
  795.   this.DIRECTION_HORIZONTAL = 1;
  796.   this.DIRECTION_VERTICAL   = 2;
  797.  
  798.   // by default, displayed in horizontal view
  799.   this.direction  = this.DIRECTION_HORIZONTAL;
  800.  
  801.   // methods
  802.   this.getItemCount = IS_Menu_getItemCount;
  803.   this.getItemPos   = IS_Menu_getItemPos;
  804.   this.getItem      = IS_Menu_getItem;
  805.   this.setItem      = IS_Menu_setItem;
  806.   this.addItem      = IS_Menu_addItem;
  807.   this.removeItem   = IS_Menu_removeItem;
  808.  
  809.   this.clearSelection = IS_Menu_clearSelection;
  810.   this.setSelected    = IS_Menu_setSelected;
  811.  
  812.   this.toHTML = IS_Menu_toHTML;
  813.   this.redraw = IS_Menu_redraw;
  814. }
  815.  
  816. // add Menu class to IS namespace
  817. IS.__proto__.Menu = IS_Menu;
  818. }
  819.